package com.jokins.common.util;

/**
 * 〈〉<br>
 *
 * @author Mr.Wang
 * @create 2024/9/7
 */
public enum BusinessCode {

    /**
     * 成功
     */
    SUCCESS(200001),

    /**
     * 参数错误
     */
    PARAM_ERROR(200000),

    /**
     * 登录错误
     */
    LOGIN_ERROR(200003),

    /**
     * 服务器错误
     */
    SERVER_ERROR(200002),

    /**
     * 系统错误
     */
    SYSTEM_ERROR(200005);


    private long code;

    BusinessCode(final long code) {
        this.code = code;
    }

    public long getCode() {
        return code;
    }

    public static BusinessCode getBusinessCode(final Integer code) {
        if (code == null) {
            return null;
        }
        for (final BusinessCode businessCode : values()) {
            if (businessCode.code == code) {
                return businessCode;
            }
        }
        throw new IllegalArgumentException("Not matching type for code:" + code);
    }
}